package com.trolls.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class CompositePortraitUi extends Composite implements HasText {

	private static CompositePortraitUiUiBinder uiBinder = GWT
			.create(CompositePortraitUiUiBinder.class);

	interface CompositePortraitUiUiBinder extends
			UiBinder<Widget, CompositePortraitUi> {
	}
	@UiField
    TextBox tbName;
	@UiField
	Image imagePortrait;
	
	public CompositePortraitUi() {
		initWidget(uiBinder.createAndBindUi(this));
		
	}
	public CompositePortraitUi(String imgPath, String name) {
		initWidget(uiBinder.createAndBindUi(this));
		imagePortrait.setTitle(name);
		imagePortrait.setAltText(name);
		imagePortrait.setUrl(imgPath);
		tbName.setValue(name);
	}


	@Override
	public String getText() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setText(String text) {
		// TODO Auto-generated method stub
		
	}
	public void setImg(Image img) {
		// on crée un nouvel objet image car celle importé à été réduite
		Image image = new Image(img.getUrl());
		//image.setHeight("400px");
		//image.setWidth("370px");
		image.setTitle(img.getTitle());
		image.setAltText(img.getAltText());
		this.imagePortrait.setUrl(img.getUrl());
		//this.imagePortrait.setHeight("400px");
		//this.imagePortrait.setWidth("370px");
		tbName.setValue(img.getAltText());
	}


	public TextBox getTbName() {
		// TODO Auto-generated method stub
		return tbName;
	}

}
